package com.mashibing.坦克游戏;

import java.awt.*;

/**
 * <简述>   坦克主体类
 * <详细描述>
 *
 * @author LiuShanshan
 * @version $Id$
 */
public class Trank {
    private int x = 200;
    private int y = 200;
    private boolean left = false;
    private boolean right = false;
    private boolean up = false;

    private boolean down = false;

    private String test = null;

    // 设置
    private Direction direction = null;
    // 设置每次移动步骤
    private Integer MOVE = 30;

    public Trank(int x, int y, Direction direction) {
        this.x = x;
        this.y = y;
        this.direction = direction;
    }

    public void paint(Graphics g) {
        if (direction != null) {
            System.out.printf("当前x和y的值：%s, %s；diretion的值：%s", x, y, direction);
            switch (direction) {
                //使用枚举的时候，如果匹配父枚举里面的枚举常量，则case 后面不需要加入枚举父类
                case LEFT:
                    x -= MOVE;
                    break;
                case RIGHT:
                    x += MOVE;
                    break;
                case UP:
                    System.out.println("调用此up");
                    y -= MOVE;
                    break;
                case DOWN:
                    y += MOVE;
                    break;
            }
            System.out.printf("当前y值：%s%n", y);
        }
        g.fillRect(x, y, 50, 50);
    }

    public void setMainTankDir() {
        System.out.printf("当前数据left，right，up， down；%s，%s，%s，%s%n", left, right, up, down);
        if (left) {
            direction = Direction.LEFT;
        } else if (right) {
            direction = Direction.RIGHT;
        } else if (up) {
            direction = Direction.UP;
        } else if (down) {
            direction = Direction.DOWN;
        } else {
            direction = null;
        }
        System.out.printf("当前direction的值：%s%n", direction);
    }


    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Direction getDirection() {
        return direction;
    }

    public void setDirection(Direction direction) {
        this.direction = direction;
    }

    public Integer getMOVE() {
        return MOVE;
    }

    public void setMOVE(Integer MOVE) {
        this.MOVE = MOVE;
    }

    public boolean isLeft() {
        return left;
    }

    public void setLeft(boolean left) {
        this.left = left;
    }

    public boolean isRight() {
        return right;
    }

    public void setRight(boolean right) {
        this.right = right;
    }

    public boolean isUp() {
        return up;
    }

    public void setUp(boolean up) {
        this.up = up;
    }

    public boolean isDown() {
        return down;
    }

    public void setDown(boolean down) {
        this.down = down;
    }
}
